SELECT 
	SalesOrderNumber,
	(
		SELECT COUNT(*)
		FROM Sales.SalesOrderDetail
		WHERE SalesOrderDetail.SalesOrderID = SalesOrderHeader.SalesOrderID
	) AS LineCount
FROM
	Sales.SalesOrderHeader